﻿@model BrnMall.Web.StoreAdmin.Models.NewsModel

@section header{
    <title>编辑内容-内容管理</title>
    <link type="text/css" rel="stylesheet" href="/admin_store/css/site.css" />
<script type="text/javascript" src="/admin_store/scripts/jquery.js"></script>
<link type="text/css" rel="stylesheet" href="/components/umeditor/themes/default/css/umeditor.css">
<script type="text/javascript" src="/components/umeditor/umeditor.config.js?v=1"></script>
<script type="text/javascript" src="/components/umeditor/umeditor.js"></script>
<script type="text/javascript" src="/components/umeditor/lang/zh-cn/zh-cn.js"></script>
<link type="text/css" rel="stylesheet" href="/components/webuploader/webuploader.css" />
<script type="text/javascript" src="/components/webuploader/webuploader.js"></script>
<script type="text/javascript" src="/admin_store/scripts/jquery.validate.js"></script>
<script type="text/javascript" src="/admin_store/scripts/jquery.validate.unobtrusive.js"></script>
<script>
    $(function () {
        var imgUploader = WebUploader.create({
            pick: '.uploadBut',
            auto: true,
            swf: '/components/webuploader/Uploader.swf',
            server: '/storeadmin/tool/upload?operation=uploadnewsimage',
            fileVal: 'upload',
            accept: {
                title: 'Images',
                extensions: '@ViewData["allowImgType"]',
                mimeTypes: '*'
            },
            fileSingleSizeLimit: @ViewData["maxImgSize"]
            });

        imgUploader.on('uploadProgress', function(file, percentage) {
            $(".uploadPreview").html("上传中...");
        });

        imgUploader.on('uploadSuccess', function(file, response) {
            var data = response._raw;
            if (data == "-1")
                $(".uploadPreview").html('图片不能为空');
            else if (data == "-2")
                $(".uploadPreview").html('图片类型不允许');
            else if (data == "-3")
                $(".uploadPreview").html('图片太大');
            else {
                $(".uploadPreview").html("<img src=\"@WorkContext.ImageCDN/upload/news/" + data + "\"  />");
                $("#ShowImg").val(data);
            }
        });

        imgUploader.on('uploadError', function(file) {
            $(".uploadPreview").html("上传失败");
        });


    });
</script>

}

@section body{
<h1 class="rightH1">
    微信小程序 &gt; 内容管理 &gt; 内容列表 &gt; <span class="rightH1-cur">编辑内容</span>
<div class="right">
<a href="@Html.Raw(ViewData["referer"].ToString())" class="menuBT"><img src="/admin_store/images/goback.jpg" />返回列表</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</h1>
@using (Html.BeginForm())
{
<div class="addTable">

<table width="100%">
  <tr>
    <td width="76px" align="right">标题：</td>
    <td>@Html.TextBoxFor(x => x.Title, new { @class = "input", size = "45" })@Html.ValidationMessageFor(x => x.Title)</td>
    </tr>
                             <tr>
    <td align="right">类型：</td>
    <td>@Html.DropDownListFor(x => x.NewsTypeId, ViewData["newsTypeList"] as List<SelectListItem>)@Html.ValidationMessageFor(x => x.NewsTypeId)
    </td>
    </tr>
    <tr>
        <td align="right">展示图片：</td>
        <td>
            <div class="upload">
                <div class="uploadPreview">
                    @if (!string.IsNullOrEmpty(Model.ShowImg))
                    {
                        <img src="@WorkContext.ImageCDN/upload/news/@Model.ShowImg" />
                    }
                    else
                    {
                        @:暂无图片
                    }
                </div>
                <div class="left">
                    <div class="uploadProgressBar"></div>
                    <div class="uploadBut">选择图片</div>
                </div>
                <div class="clear"></div>
                <div class="left"><label>&nbsp;长方形建议尺寸800x400，正方形建议800x800</label></div>
            </div>
            @Html.TextBoxFor(x => x.ShowImg, new { @class = "hide" })
            @Html.ValidationMessageFor(x => x.ShowImg)
        </td>
    </tr>
    <tr style="display: none">
        <td align="right">Url：</td>
        <td>@Html.TextBoxFor(x => x.Url, new { @class = "input", size = "45" })@Html.ValidationMessageFor(x => x.Url)</td>
    </tr>

          <tr>
    <td align="right">内容：</td>
    <td>
        <script name="Body" id="bmaEditor" type="text/plain">
            @Html.Raw(Model.Body)
    </script>
         <script type="text/javascript">
             window.UMEDITOR_CONFIG.imageUrl = "" + "/storeadmin/tool/upload?operation=uploadnewseditorimage";
             UM.getEditor('bmaEditor');
        </script>
    </td>
    </tr>


      <tr>
    <td align="right">排序：</td>
    <td>@Html.TextBoxFor(x => x.DisplayOrder, new { @class = "input", size = "3" })@Html.ValidationMessageFor(x => x.DisplayOrder)</td>
    </tr>
    <tr>
        <td align="right">是否显示：</td>
    <td>
        <p>
            <label>@Html.RadioButtonFor(x => x.IsShow, 1, new { @class = "checkbox" })是</label>
            <label>@Html.RadioButtonFor(x => x.IsShow, 0, new { @class = "checkbox" })否</label>
            <br />
        </p>
    </td>
    </tr>

        <tr>
        <td align="right">是否置顶：</td>
    <td>
        <p>
            <label>@Html.RadioButtonFor(x => x.IsTop, 1, new { @class = "checkbox" })是</label>
            <label>@Html.RadioButtonFor(x => x.IsTop, 0, new { @class = "checkbox" })否</label>
            <br />
        </p>
    </td>
    </tr>

    <tr >
        <td align="right">是否置首：</td>
        <td>
            <p>
                <label>@Html.RadioButtonFor(x => x.IsHome, 1, new { @class = "checkbox" })是</label>
                <label>@Html.RadioButtonFor(x => x.IsHome, 0, new { @class = "checkbox" })否</label>
                <br />
            </p>
        </td>
    </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>
    <a href="" class="addBt" id="sumbitBut" ><img src="/admin_store/images/submit.jpg" /></a>
        <script type="text/javascript">
            $(function () {
                $("#sumbitBut").click(function () {
                    $("form:first").submit();
                    return false;
                })
            });
        </script>
    </td>
    </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
</table>
</div>
}
}